<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        class Dog{
            constructor(name,age){
                this.name=name
                this.age=age
            }
            cry(){
                console.log(this);   //x()时 this时undefined
                console.log(`我的名字是:${this.name},我的年龄是${this.age}岁`);
            }
        }
        const d=new Dog('旺财',2)
        const x = d.cry
        x()   //此处属于cry的直接调用 类中所有定义的方法 浏览器在运行是，全都加上了use strict


        // 开启严格模式和不开启严格模式的区别
      /*   function demo1(){
            'use strict'
            console.log(this);   //undefined
        }
        function demo2(){
            console.log(this);   //window
        }

        demo1()
        demo2() */

    </script>
</body>
</html>



